<!--
 * @Descripttion: 新客福包设置
 * @Author: xiao li
 * @Date: 2020-07-06 12:17:07
 * @LastEditors: xiao li
 * @LastEditTime: 2021-04-29 11:32:57
-->
<template>
  <div class="lb-edit-card">
    <top-nav :isBack="true"></top-nav>
    <div class="page-main">
      <div style="height:20px"></div>
      <el-form
        @submit.native.prevent
        :model="subForm"
        ref="subForm"
        :rules="subFormRules"
        label-width="140px"
        class="basic-form"
      >
        <el-form-item label="员工自己发福包" prop="redbag_staff_switch">
          <el-radio-group v-model="subForm.redbag_staff_switch">
            <el-radio :label="0">{{$t('action.OFF')}}</el-radio>
            <el-radio :label="1">{{$t('action.ON')}}</el-radio>
          </el-radio-group>
          <lb-tool-tips>开启或关闭员工自己在小程序端发布新客福包的权限</lb-tool-tips>
        </el-form-item>
        <el-form-item>
          <lb-button @click="submitFormInfo(2)" type="primary">{{$t('action.save')}}</lb-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      // 基本信息
      subForm: {
        redbag_staff_switch: 0
      },
      subFormRules: {
        redbag_staff_switch: {
          required: true,
          type: Number,
          message: '员工自己发福包',
          trigger: 'change'
        }
      }
    }
  },
  async created () {
    await this.submitFormInfo(1)
  },
  methods: {
    getCover (imgs) {
      this.subForm.passenger_cover = imgs
    },
    async submitFormInfo (type) {
      let subForm = JSON.parse(JSON.stringify(this.subForm))
      if (type === 1) {
        subForm = ''
      }
      let { code, data } = await this.$api.cashDefaultSetting(subForm)
      if (code !== 200) return
      if (type === 1) {
        for (let key in this.subForm) {
          this.subForm[key] = data[key]
        }
      } else {
        this.$message.success(this.$t('tips.successSub'))
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.lb-edit-card {
  width: 100%;
  .el-input,
  .el-select,
  .lb-input-number,
  .el-cascader {
    width: 400px;
  }
}
</style>
